package edu.ucsd.cse135.gas.action.chair;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.ucsd.cse135.gas.bean.chair.AnalyticsBean;
import edu.ucsd.cse135.gas.logic.chair.Applications;
import edu.ucsd.cse135.gas.resources.Constants;

public class ShowApplicantsAction extends Action {

	public ShowApplicantsAction() {
		super();
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
		
		AnalyticsBean analyticsBean = (AnalyticsBean)form;
		
		if(analyticsBean.getType().equals("specialization"))
		{
			request.setAttribute("users", Applications.getSpecializationsUsers(analyticsBean.getId()));
		}
		else if(analyticsBean.getType().equals("disciplines"))
		{
			request.setAttribute("users", Applications.getDisciplinesUsers(analyticsBean.getId()));
		}
		
		return mapping.findForward(Constants.SUCCESS);	
	}	
}